package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.StitchIORequest;
import com.alks.function.service.stockdept.pcfactorystockquery.ISoleIoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
@RequiredArgsConstructor
@RoleCheck(prgIds = {"160120"})
public class SoleXDIOController {
    private final ISoleIoService service;

    private final String partType = "2";

    @WebLogger
    @PostMapping("/getSoleXDIOQuery")
    @ApiOperation(value = "鞋垫收发料输入-收发明细查询-查询", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo getSoleXDIOQuery(@RequestParam@ApiParam("指令") String lotNo,
                                         @RequestParam(required = false) Boolean mergeFlag) {
        return service.getSoleIOQuery(lotNo,partType, mergeFlag);
    }

    @WebLogger
    @PutMapping("/soleXDIOAdd")
    @ApiOperation(value = "鞋垫收发料输入-收发明细新增-新增", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo soleIOAdd(@RequestBody StitchIORequest request,
                                    @RequestParam@ApiParam("长度") Integer length) {
        return service.soleIOAdd(request,length,partType);
    }

    @WebLogger
    @PutMapping("/soleXDIOUp")
    @ApiOperation(value = "鞋垫收发料输入-收发明细更新-更新", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo soleXDIOUp(@RequestBody StitchIORequest request) {
        return service.soleIOUp(request,partType);
    }

    @WebLogger
    @PostMapping("/soleXDIODetail")
    @ApiOperation(value = "鞋垫收发料输入-收发明细删除-删除", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo soleXDIODelete(@RequestParam@ApiParam("入库单号") String slipNo) {
        return service.soleIODelete(slipNo,partType);
    }

    @WebLogger
    @PostMapping("/soleXDIO/slipCreat")
    @ApiOperation(value = "生成单据号-新增", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo soleSlipNoCreat1(@RequestParam @ApiParam(value = "指令",required = true) String lotNo) {
        String printNo = service.soleSlipNoCreat(lotNo,partType);
        return ResponseInfo.ok(printNo);
    }

    @WebLogger
    @PostMapping("/soleXDIO/printf")
    @ApiOperation(value = "打印查询-新增", tags = "仓储部-仓储工厂作业-鞋垫收发料输入")
    public ResponseInfo soleIoPrintf1(@RequestParam String printNo) {
        return ResponseInfo.ok(service.ioPrintf(printNo,partType));
    }
}
